/**
 * 
 */
package fr.cephb.joperon.webapp.tag;

import java.io.IOException;

import javax.servlet.jsp.JspWriter;

import fr.cephb.joperon.core.ProjectAcnSuffix;

/**
 * @author lindenb
 *
 */
public class PrjFinLink extends AbstractEmptyTag {
	private static final long serialVersionUID = 1L;
	String pid=null;
	String fix=null;
	/**
	 * 
	 */
	public PrjFinLink() {
	}

	public void setPid(String pid) {
		this.pid = pid;
		}
	
	
	public void setFix(String fix) {
		this.fix = fix;
		}
	
	/* (non-Javadoc)
	 * @see fr.cephb.joperon.webapp.tag.AbstractEmptyTag#print(javax.servlet.jsp.JspWriter)
	 */
	@Override
	public void print(JspWriter out) throws IOException
		{
		String url=null;
		if(!(this.fix==null || fix.length()==0))
			{
			try {
				ProjectAcnSuffix suffix= ProjectAcnSuffix.valueOf(fix.substring(0,1));
				switch(suffix)
					{
					case D: url="act=prjdna&amp;acn="+pid+"_"+fix;
					}
				
			} catch (EnumConstantNotPresentException e) {
				//ignore
				return;
				}
			}
		if(url!=null)
			{
			out.println("<a href='operon?"+url+"'>");
			}
		out.println(this.fix);
		if(url!=null)
			{
			out.println("</a>");
			}
		}

	@Override
	public void release() {
		this.pid=null;
		this.fix=null;
		}
}
